﻿@model Model.AppUserList
@{
    ViewBag.Title = "DeliveryBox";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script src="../../Scripts/jqueryeasyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.easy.ui.extend.js" type="text/javascript"></script>
    <script src="../../Scripts/Common.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            onLoadDate();
            InitGrid();
        });

        HandleDom.ClassTriggerClick("icon-reload", function () {
            InitGrid();
        });
        HandleDom.ClassTriggerClick("icon-exporter", function () {
            ExporterExcel();
        });
        function onLoadDate() {
            $('#selDBoxType').combobox('setValue', '0');
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#StartDate").datebox("setValue", strDate);
            $("#EndDate").datebox("setValue", strDate);
        }

        function InitGrid() {
            var txtDBBCBATCHNO = $('#txtDBBCBATCHNO').val();
            var startDate = $('#StartDate').datebox('getValue');
            var endDate = $('#EndDate').datebox('getValue');
            var seedtype = $('#selDBoxType').combobox('getValue');
            queryParams = {
                dbbcBatchNo: txtDBBCBATCHNO,
                startDate: startDate,
                endDate: endDate,
                seedType: seedtype
            }
            HandleData.InitDataGrid('dg', '/DeliveryBox/InitJsonResult', 'toolbar', queryParams, 'ID', false);
        }


        function GetExcel() {
            var form = $('#query');
            var seedtype = $('#selDBoxType').combobox('getValue');
            var barCodeNumber = $.trim($("#txtNumber").attr("value"));
            if (barCodeNumber == "" || barCodeNumber < 0) {
                layer.msg("请正确输入数量！", 1);
                return false;
            }
            if (seedtype == "0") {
                layer.msg("请选择要生成的箱码类型！", 1);
                return false;
            }
            form.form('submit', {
                url: '@Url.Content("~/DeliveryBox/GetLmDeliveryBox")' + '?BarCodeNumber=' + barCodeNumber + "&seedType=" + seedtype,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        $("#txtDBBCBATCHNO").val(data.msg);
                        layer.msg("生成成功！", 1);
                        InitGrid();
                    } else {
                        layer.msg(data.msg, 1);
                    }
                }
            });
            }
            function ExporterExcel() {
                var form = $('#query');
                var dbbcBatchNo = $.trim($("#txtDBBCBATCHNO").attr("value"));
                var startDate = $('#StartDate').datebox('getValue');
                var endDate = $('#EndDate').datebox('getValue');
                form.form('submit', {
                    url: '@Url.Content("~/DeliveryBox/ExporterExcel")' + '?dbbcBatchNo=' + dbbcBatchNo + "&startDate=" + startDate + "&endDate=" + endDate,
                    success: function (data) {
                        eval('data=' + data);
                        if (data.success) {
                            layer.msg("导出成功！", 1);
                        } else {
                            layer.msg(data.msg, 1);
                        }
                    }
                });
            }
    </script>
}
<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>批次号:
                    </td>
                    <td>
                        <input id="txtDBBCBATCHNO" name="txtDBBCBATCHNO" style="width: 154px" validtype="integer['#txtDBBCBATCHNO']" />
                    </td>
                    <td>生成时间:
                    </td>
                    <td>
                        <input class="easyui-datebox" id="StartDate" name="StartDate" style="width: 140px;" />
                    </td>
                    <td>~：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="EndDate" name="EndDate" style="width: 140px;" validtype="compareDate['#StartDate']" />
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid();">查询</a>

                    </td>
                </tr>
                <tr>
                    <td>生成类型:
                    </td>
                    <td>
                        <input id="selDBoxType" class="easyui-combobox" name="selDBoxType" style="width: 155px;" data-options="required:true,valueField:'FIELDVALUE',textField:'LOOKUP',url:'@Url.Action("GetDeliveryBoxType", "DeliveryBox", new { isDefault = true, defaultValue = "请选择箱码类型" })',editable:false">
                    </td>
                    <td>数  量:
                    </td>
                    <td>
                        <input id="txtNumber" name="txtNumber" style="width: 154px" />
                    </td>
                    <td>
                        <a id="btnGet" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="GetExcel()">生成</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="箱码管理" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'ID',width:50">序号</th>
                    <th data-options="field:'DBBCBATCHNO',width:150">生成批次号</th>
                    <th data-options="field:'DBBCCODE',width:120">箱号</th>
                    <th data-options="field:'OPRNO',width:120">操作人</th>
                    <th data-options="field:'CREATETIME',width:180">时间</th>
                </tr>
            </thead>
        </table>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =false },
              new FunctionModule(){Name = "Edit",IsEnable =false },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              
            }
        }
    }
})

</body>

